< previous page page_404 next page >

Page 404
9f31265bb40b592b1929e18a47ab28e5.gif
      Print #mintHandle, strWrite & vbCrLf
      WriteLine = True
   End If

End Function
You can see that you use the Print statement with the file handle number you retrieved from the Class_Initialize() event. Print is a built-in statement in Visual Basic thats used to write information to a file.
Closing the File
Once the write process is finished, the file should be closed. The sample TextStream class implements a CloseFile() method to close the file handle:
9f31265bb40b592b1929e18a47ab28e5.gif
Public Function CloseFile() As Boolean
   ' Valid File Handle ?
   If mintHandle <> 0 Then
      Close #mintHandle
      mintHandle = 0

      CloseFile = True
   Else
      CloseFile = False
   End If
End Function
The CloseFile() method first checks the file handle to see whether its valid. Any number other than 0 is a valid file handle. CloseFile() then calls the Close statement to close the particular file handle stored in the object. It also sets the file handle to 0; this way, if any other methods are called after the file is closed, no errors will occur. In every method of this class, the file handle is checked to see whether its valid prior to performing any operation on the file.
Reading from a Text File
Now that youve seen how to write information into a file, lets look at how to read information out of a file. You still use the TextStream class to accomplish this, but you simply use other methods of the class for reading the file.

 
< previous page page_404 next page >

If you like this book, buy it!